#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75636-setsebool.sh
# Version:    1.0
# Date:       2013/12/17
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    03系统安全功能-01SELinux-03SELinux重要命令-02SELinux策略值-02setsebool策略值设定
# Notes:      setsebool策略值特定
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/17
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ../../lib/XmlParse.sh
source ./lib/Selib.sh

function CleanData ()
{
  setsebool allow_console_login=${CURRENT_STATUS}
  EchoInfo "75636-setsebool.sh执行完毕"
}

trap "CleanData" EXIT

CheckSElinuxStatus

EchoInfo "通过getsebool命令获取当前策略值"
CURRENT_STATUS=`getsebool allow_console_login|cut -d " " -f3`

EchoInfo "命令setsebool在不加参数P的情况下只是暂时修改策略值，接下来检验该命令执行结果是否正确"

setsebool allow_console_login=0
[ "`getsebool allow_console_login|cut -d " " -f3`" == "off" ]
EchoResult "setsebool allow_console_login=0 执行结果正确"

setsebool allow_console_login=1
[ "`getsebool allow_console_login|cut -d " " -f3`" == "on" ]
EchoResult "setsebool allow_console_login=1 执行结果正确"

setsebool allow_console_login=off
[ "`getsebool allow_console_login|cut -d " " -f3`" == "off" ]
EchoResult "setsebool allow_console_login=off 执行结果正确"

setsebool allow_console_login=on
[ "`getsebool allow_console_login|cut -d " " -f3`" == "on" ]
EchoResult "setsebool allow_console_login=0 执行结果正确"

